package me.caofeng.pojo;

import java.io.Serializable;
import java.util.List;

/**
 * Copyright © 2017曹峰. All rights reserved.
 *
 * @Prject: mall
 * @Package: me.caofeng.pojo
 * @Description: 分页对象
 * @Author: 曹峰 blog.caofeng.me
 * @Date: 2017-06-24 23:13
 * @Version: V1.0
 */
public  class Page<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 当前页
     */
    private int pageNumber;

    /**
     * 每页的数量
     */
    private int pageSize;

    /**
     * 当前页的数量
     */
    private int size;

    /**
     * 结果集
     */
    private T list;

    public Page() {
    }

    public Page(int pageNumber, int pageSize) {
        if (pageNumber <= 1 ){
            pageNumber = 0 ;
        }else {
            pageNumber = (pageNumber-1) * pageSize;
        }
        this.pageNumber = pageNumber;
        this.pageSize = pageSize;
    }

    public Page(int pageNumber, int pageSize, int size, T list) {
        this.pageNumber = pageNumber;
        this.pageSize = pageSize;
        this.size = size;
        this.list = list;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public int getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(int pageNumber) {
        this.pageNumber = pageNumber;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public T getList() {
        return list;
    }

    public void setList(T list) {
        this.list = list;
    }

    @Override
    public String toString() {
        return "Page{" +
                "pageNumber=" + pageNumber +
                ", pageSize=" + pageSize +
                ", size=" + size +
                ", list=" + list +
                '}';
    }
}


